//
//  shuixiazidingyiCellCollectionViewCell.m
//  UI_HLJ_Frame
//
//  Created by  毕宏伟 on 15/7/7.
//  Copyright (c) 2015年 毕宏伟. All rights reserved.
//

#import "shuixiazidingyiCellCollectionViewCell.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
#import "shuixiazidingyiTableViewCell.h"
#import "shuixiaDetailModel.h"
#import "UIImageView+WebCache.h"
#import "shuixiamerchantModel.h"
#import "shuixiazidingyitwoTableViewCell.h"
#import "shuixiataocanPagemerchantModel.h"
#import "shuixiataocanPageModel.h"
@implementation shuixiazidingyiCellCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self =[super initWithFrame:frame];
    if (self) {
        
        self.tableView =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-64) style:UITableViewStylePlain];
        self.tableView.delegate =self;
        self.tableView.dataSource =self;
        [self.contentView addSubview:self.tableView];
        [_tableView release];
        
        
        
    }
    return self;
}

#pragma mark 实现tableview的协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.flag==0) {
        return self.onepageArr.count;
    }
    else
    {
       return self.twoPageArr.count;
    }
}





- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (self.flag==0) {
        NSString *reuse =@"reuse";
        shuixiazidingyiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse
                                              
                                              ];
        
        if (!cell) {
            cell =[[[shuixiazidingyiTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse]autorelease];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        shuixiaDetailModel *shui =self.onepageArr[indexPath.row];
        
        [cell.bigImage sd_setImageWithURL:[NSURL URLWithString:shui.cover_path]];
        
        cell.titleLabel.text =shui.title;
        
        shuixiamerchantModel *mer =self.merchantArr[indexPath.row];
        
        cell.addressLabel.text =mer.name;
        
        cell.shoucangLabel.text =[NSString stringWithFormat:@"收藏:%@",shui.collectors_count];
    
        
        return cell;
    }
    else
    {
        NSString *reuse1 =@"reuse1";
        shuixiazidingyitwoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse1];
        if (!cell) {
            cell =[[[shuixiazidingyitwoTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse1]autorelease];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        shuixiataocanPageModel * shui =self.twoPageArr[indexPath.row];
        [cell.bigImage sd_setImageWithURL:[NSURL URLWithString:shui.cover_path]];
        cell.titleLabel.text =shui.title;
        cell.priceLabel.text =[NSString stringWithFormat:@"💰%@",shui.actual_price];
        shuixiataocanPagemerchantModel *mer =self.merchanttwoArr[indexPath.row];
        cell.zuozheLabel.text =mer.name;
        
        
        return cell;
    
    }
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.flag ==0) {
        return 300;
    }
    else
    {
        return 300;
    }
}



@end
